home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
win
/
pascal
/
fcsrc.exe
/
FCINI.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-06-04
|
14KB
|
493 lines
unit FCINI;
{$R FCINI}
interface
uses WinTypes, WinProcs, WObjects, WinDOS, Strings, FCDLGS;
{$I fc.inc}
const
id_SetupDlg = 300;
id_DirEdit = 301;
id_FltrEdit = 302;
id_PrmEdit = 303;
id_AppEdit = 304;
id_ItmLabel = 305;
id_GrpLabel = 306;
id_NeedsAppCheck = 307;
id_MinRadio = 308;
id_WinRadio = 309;
id_MaxRadio = 310;
id_AppLabel = 311;
cm_New = 321;
cm_Open = 322;
cm_Save = 323;
cm_SaveAs = 324;
cm_Install = 325;
cm_Use = 326;
cm_Cancel = 327;
cm_FindDir = 328;
cm_FindApp = 329;
cm_HelpIndex = 330;
cm_HelpEdit = 331;
type
PTransferRec = ^TransferRec;
TransferRec = record
EDir: array[0..fsPathName] of Char;
EFltr: array[0..fsFileName+fsExtension] of Char;
EPrm: array[0..fsPathName] of Char;
EApp: array[0..fsPathName] of Char;
EItm: array[0..PrgManItm] of Char;
EGrp: array[0..PrgManGrp] of Char;
CNeedsApp: Word;
RMin: Word;
RWin: Word;
RFull: Word;
LApp: array[0..LabelLen] of Char;
end;
PFCSDlg = ^FCSDlg;
FCSDlg = object(TDialog)
StartSctnName: array[0..PrgManItm] of Char;
SctnName: PChar;
FCSHelpFile: array[0..fsPathName] of Char;
DirEdit: PEdit;
FltrEdit: PEdit;
PrmEdit: PEdit;
AppEdit: PEdit;
ItmLabel: PStatic;
GrpLabel: PStatic;
NeedsAppCheck: PCheckBox;
MinRadio: PRadioButton;
WinRadio: PRadioButton;
MaxRadio: PRadioButton;
AppLabel: PStatic;
NeedsAppIsChecked: Word;
MinIsChecked: Word;
WinIsChecked: Word;
MaxIsChecked: Word;
NewInstall: boolean;
constructor Init(AParent: PWindowsObject; ASctnName: PChar);
procedure SetupWindow; virtual;
procedure PopMessage(text: PChar);
procedure CMNew(var Msg: TMessage);
virtual cm_First + cm_New;
procedure CMOpen(var Msg: TMessage);
virtual cm_First + cm_Open;
procedure CMSave(var Msg: TMessage);
virtual cm_First + cm_Save;
procedure CMSaveAs(var Msg: TMessage);
virtual cm_First + cm_SaveAs;
procedure CMInstall(var Msg: TMessage);
virtual cm_First + cm_Install;
procedure CMUse(var Msg: TMessage);
virtual cm_First + cm_Use;
procedure CMCancel(var Msg: TMessage);
virtual cm_First + cm_Cancel;
procedure CMFindDir(var Msg: TMessage);
virtual cm_First + cm_FindDir;
procedure CMFindApp(var Msg: TMessage);
virtual cm_First + cm_FindApp;
procedure CMHelpIndex(var Msg: TMessage);
virtual cm_First + cm_HelpIndex;
procedure CMHelpEdit(var Msg: TMessage);
virtual cm_First + cm_HelpEdit;
procedure CMNeedsAppCheck(var Msg: TMessage);
virtual id_First + id_NeedsAppCheck;
function CanClose: boolean; virtual;
procedure SetIniData(TheSection: PChar);
procedure ClearModFlags;
procedure FixName(AName: PChar);
procedure SetTitle;
procedure UpdateCheck;
end;
procedure GetIniData(PTRec: PTransferRec; Section: PChar);
implementation
procedure FCSDlg.PopMessage(text: PChar);
begin
MessageBox(HWindow, text, 'Message', mb_Ok);
end;
constructor FCSDlg.Init(AParent: PWindowsObject; ASctnName: PChar);
begin
TDialog.Init(AParent, PChar(id_SetupDlg));
SctnName := ASctnName;
{StrLCopy(SctnName, ASctnName, PrgManItm+1);}
StrCopy(StartSctnName, SctnName);
DirEdit := New(PEdit, InitResource(@Self, id_DirEdit, fsPathName+1));
FltrEdit := New(PEdit, InitResource(@Self, id_FltrEdit, fsFileName+fsExtension+1));
PrmEdit := New(PEdit, InitResource(@Self, id_PrmEdit, fsPathName+1));
AppEdit := New(PEdit, InitResource(@Self, id_AppEdit, fsPathName+1));
ItmLabel := New(PStatic, InitResource(@Self, id_ItmLabel, PrgManItm+1));
GrpLabel := New(PStatic, InitResource(@Self, id_GrpLabel, PrgManGrp+1));
NeedsAppCheck := New(PCheckBox, InitResource(@Self, id_NeedsAppCheck));
MinRadio := New(PRadioButton, InitResource(@Self, id_MinRadio));
WinRadio := New(PRadioButton, InitResource(@Self, id_WinRadio));
MaxRadio := New(PRadioButton, InitResource(@Self, id_MaxRadio));
AppLabel := New(PStatic, InitResource(@Self, id_AppLabel, LabelLen+1));
end;
procedure FCSDlg.SetupWindow;
var
Buffer: array[0..fsPathName] of Char;
Temp1: array[0..fsFileName] of Char;
Temp2: array[0..fsExtension] of Char;
begin
TDialog.SetupWindow;
StrPCopy(Buffer, ParamStr(0));
FileSplit(Buffer, FCSHelpFile, Temp1, Temp2);
if FCSHelpFile[3] = #0 then FCSHelpFile[2] := #0;
StrCat(FCSHelpFile, '\');
StrCat(FCSHelpFile, HelpName);
SetTitle;
AppLabel^.SetText('Serving &App:');
MinIsChecked := MinRadio^.GetCheck;
WinIsChecked := WinRadio^.GetCheck;
MaxIsChecked := MaxRadio^.GetCheck;
NeedsAppIsChecked := NeedsAppCheck^.GetCheck;
UpdateCheck;
NewInstall := FALSE;
end;
procedure FCSDlg.UpdateCheck;
begin
if NeedsAppCheck^.GetCheck = bf_Checked then
begin
EnableWindow(AppLabel^.HWindow, TRUE);
end
else
begin
EnableWindow(AppLabel^.HWindow, FALSE);
end;
end;
procedure FCSDlg.CMNeedsAppCheck(var Msg: TMessage);
begin
if Msg.LParamHi = bn_Clicked then UpdateCheck;
end;
procedure FCSDlg.CMFindDir(var Msg: TMessage);
var
TRec: array[0..fsPathName] of Char;
PD: PDialog;
begin
PD := New(PDirDlg, Init(@Self, TRec));
if Application^.ExecDialog(PD) = id_Ok then
begin
if TRec[2] = #0 then StrCat(TRec, '\');
DirEdit^.SetSelection(0, 32767);
DirEdit^.Insert(StrLower(TRec));
end;
end;
procedure FCSDlg.CMFindApp(var Msg: TMessage);
var
TRec: array[0..fsPathName] of Char;
PD: PDialog;
begin
PD := New(PExeDlg, Init(@Self, TRec));
if Application^.ExecDialog(PD) = id_Ok then
begin
AppEdit^.SetSelection(0, 32767);
AppEdit^.Insert(StrLower(TRec));
UpdateCheck;
end;
end;
procedure FCSDlg.CMNew(var Msg: TMessage);
begin
GetIniData(TransferBuffer, '_default');
{StrCopy(SctnName, 'noname');}
SctnName[0] := #0;
TransferData(tf_SetData);
SetTitle;
UpdateCheck;
ItmLabel^.SetText('Not yet installed');
GrpLabel^.SetText('');
end;
procedure FCSDlg.CMOpen(var Msg: TMessage);
var
Buffer: array[0..PrgManItm] of Char;
PD: PDialog;
begin
PD := New(PSctnDlg, Init(@Self, Buffer, Sizeof(Buffer)));
if Application^.ExecDialog(PD) = id_Ok then
begin
StrCopy(SctnName, Buffer);
GetIniData(TransferBuffer, SctnName);
TransferData(tf_SetData);
SetTitle;
UpdateCheck;
ClearModFlags;
end;
end;
procedure FCSDlg.ClearModFlags;
begin
DirEdit^.ClearModify;
FltrEdit^.ClearModify;
PrmEdit^.ClearModify;
AppEdit^.ClearModify;
NeedsAppIsChecked := NeedsAppCheck^.GetCheck;
MinIsChecked := MinRadio^.GetCheck;
WinIsChecked := WinRadio^.GetCheck;
MaxIsChecked := MaxRadio^.GetCheck;
NewInstall := FALSE;
end;
procedure FCSDlg.CMSave(var Msg: TMessage);
begin
if SctnName[0] = #0 then
CMSaveAs(Msg)
else
begin
SetIniData(SctnName);
ClearModFlags;
end;
end;
procedure FCSDlg.CMInstall(var Msg: TMessage);
var
PD: PDialog;
PItm: array[0..PrgManItm] of Char;
PGrp: array[0..PrgManGrp] of Char;
begin
PD := New(PInstallDlg, Init(@Self, SctnName, PItm, PGrp));
if Application^.ExecDialog(PD) = id_Ok then
begin
ItmLabel^.SetText(PItm);
GrpLabel^.SetText(PGrp);
NewInstall := TRUE;
end;
end;
procedure FCSDlg.CMSaveAs(var Msg: TMessage);
var
PItm: array[0..PrgManItm] of Char;
PGrp: array[0..PrgManGrp] of Char;
PD: PDialog;
begin
StrCopy(PItm, SctnName);
PD := New(PSaveAsDlg, Init(@Self, PItm));
if Application^.ExecDialog(PD) = id_Ok then
begin
StrCopy(SctnName, PItm);
FixName(SctnName);
GetPrivateProfileString(SctnName, 'ITEMNAME', 'Not yet installed',
PItm, PrgManItm+1, IniName);
GetPrivateProfileString(SctnName, 'GROUPNAME', '', PGrp,
PrgManGrp+1, IniName);
ItmLabel^.SetText(PItm);
GrpLabel^.SetText(PGrp);
SetIniData(SctnName);
SetTitle;
ClearModFlags;
end;
end;
procedure FCSDlg.CMUse(var Msg: TMessage);
begin
FCSDlg.TransferData(tf_GetData);
if Can